package com.frinder.demo1;

import akka.actor.ActorRef;
import akka.actor.Props;
import akka.actor.UntypedActor;

import java.util.Arrays;

/**
 * Created by frinder on 2017/7/11.
 */
public class HelloWorld extends UntypedActor {

    @Override
    public void preStart() throws Exception {
        // create the greeter actor
        final String name = "greeter";
        final ActorRef greeter = getContext().actorOf(Props.create(Greeter.class), name);
        // tell it to perform the greeting
//        greeter.tell(Greeter.Msg.GREET, getSelf());
        greeter.tell(new Message(18, Arrays.asList("123", "abc")), getSelf());
    }

    @Override
    public void onReceive(Object msg) throws Exception {
//        if (msg == Greeter.Msg.DONE) {
//            // when the greeter is done, stop this actor and with it the application
//            getContext().stop(getSelf());
//        } else {
//            unhandled(msg);
//        }

        System.out.println(getClass().getName() + ", " + msg);
    }
}
